package Test.Exam;

import java.util.Scanner;

/**
 * @ClassName problem_5
 * @since: 2024/3/9 19:21
 * @auth: kirito
 * @description:
 **/
public class problem_7 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        String coins = sc.next();

        int op = 0;
        int count = 0;
        for (int i = 0; i < n; i++) {
            if (coins.charAt(i) == '1') {
                count++;
                if (count == 1) {
                    op++;
                }
            } else {
                count++;
            }

        }
        if (count != 0) {
            System.out.println(-1);
        } else {
            System.out.println(op);
        }

    }


}
